from django.forms.widgets import Widget
from django.utils.safestring import mark_safe

class Textarea(Widget):
    def __init__(self, attrs=None):
        # The 'rows' and 'cols' attributes are required for HTML correctness.
        self.attrs = {'cols': '40', 'rows': '10'}
        if attrs:
            self.attrs.update(attrs)
            
        def render(self, name, value, attrs=None):
            if value is None: value = ''
            final_attrs = self.build_attrs(attrs, name=name)
            return mark_safe(
                u'XXX<textarea%s>%s</textarea>' % (
                    flatatt(final_attrs),
                    conditional_escape(force_unicode(value))
                )
            )